<%-- 
    Document   : CheckLogin
    Created on : Nov 20, 2012, 2:09:52 PM
    Author     : Thanh
--%>
<%@page import="data.UserDAL"%>
<%@page import="data.UserEntity"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <jsp:useBean id="user" class="data.UserEntity"/>
        <jsp:setProperty name="user" property="*"/>
        <%
        if(UserDAL.checkLogin(user.getUsername(), user.getPassword())){
            UserEntity entity = UserDAL.setLogin(user.getUsername());
            session.setAttribute("user", entity);
        %>
        <h1>Login successful</h1>
        <%
               }else{
        %>
        <h1>Login fail, please check UserName and Password. <a href="Login.jsp">Try again</a></h1>
        <%
               }
        UserEntity entity = (UserEntity) session.getAttribute("user");
        %>
        
        <h1>Role: <%=entity.getRole()%> </h1>
    </body>
</html>
